using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
    public class ContrInfo
    {
		#region Local Variable
        public enum Field
        {
            Contract,
			LimitAmt,
			LimitAmt1,
			CummulativeAmt,
			RemainingAmt,
			ContractHolder,
			Desc,
			LimitAmtV1,
			LimitAmtV2,
			LimitAmtV3,
			LimitAmtV4,
			LimitAmtV5,
			Desc1V1,
			Desc1V2,
			Desc1V3,
			Desc1V4,
			Desc1V5,
			Desc2V1,
			Desc2V2,
			Desc2V3,
			Desc2V4,
			Desc2V5,
			Date1,
			Date2,
			Date3,
			Date4,
			Date5,
			aYear,
			BudgetGroup,
			Department,
			Employee,
			SharedBudget,
			aYearBudgetGroup,
			ImpDate,
			UpdDate,
			sort1,
			sort2,
            CreatedBy,
            ModifiedBy,
            CreatedDate,
            ModifiedDate,

        }
		private String _Contract;
		public String Contract
		{
			get { return _Contract; }
			set { _Contract = value; }
		}
		private Double _LimitAmt;
		public Double LimitAmt
		{
			get { return _LimitAmt; }
			set { _LimitAmt = value; }
		}
		private Double _LimitAmt1;
		public Double LimitAmt1
		{
			get { return _LimitAmt1; }
			set { _LimitAmt1 = value; }
		}
		private Double _CummulativeAmt;
		public Double CummulativeAmt
		{
			get { return _CummulativeAmt; }
			set { _CummulativeAmt = value; }
		}
		private Double _RemainingAmt;
		public Double RemainingAmt
		{
			get { return _RemainingAmt; }
			set { _RemainingAmt = value; }
		}
		private String _ContractHolder;
		public String ContractHolder
		{
			get { return _ContractHolder; }
			set { _ContractHolder = value; }
		}
		private String _Desc;
		public String Desc
		{
			get { return _Desc; }
			set { _Desc = value; }
		}
		private Double _LimitAmtV1;
		public Double LimitAmtV1
		{
			get { return _LimitAmtV1; }
			set { _LimitAmtV1 = value; }
		}
		private Double _LimitAmtV2;
		public Double LimitAmtV2
		{
			get { return _LimitAmtV2; }
			set { _LimitAmtV2 = value; }
		}
		private Double _LimitAmtV3;
		public Double LimitAmtV3
		{
			get { return _LimitAmtV3; }
			set { _LimitAmtV3 = value; }
		}
		private Double _LimitAmtV4;
		public Double LimitAmtV4
		{
			get { return _LimitAmtV4; }
			set { _LimitAmtV4 = value; }
		}
		private Double _LimitAmtV5;
		public Double LimitAmtV5
		{
			get { return _LimitAmtV5; }
			set { _LimitAmtV5 = value; }
		}
		private String _Desc1V1;
		public String Desc1V1
		{
			get { return _Desc1V1; }
			set { _Desc1V1 = value; }
		}
		private String _Desc1V2;
		public String Desc1V2
		{
			get { return _Desc1V2; }
			set { _Desc1V2 = value; }
		}
		private String _Desc1V3;
		public String Desc1V3
		{
			get { return _Desc1V3; }
			set { _Desc1V3 = value; }
		}
		private String _Desc1V4;
		public String Desc1V4
		{
			get { return _Desc1V4; }
			set { _Desc1V4 = value; }
		}
		private String _Desc1V5;
		public String Desc1V5
		{
			get { return _Desc1V5; }
			set { _Desc1V5 = value; }
		}
		private String _Desc2V1;
		public String Desc2V1
		{
			get { return _Desc2V1; }
			set { _Desc2V1 = value; }
		}
		private String _Desc2V2;
		public String Desc2V2
		{
			get { return _Desc2V2; }
			set { _Desc2V2 = value; }
		}
		private String _Desc2V3;
		public String Desc2V3
		{
			get { return _Desc2V3; }
			set { _Desc2V3 = value; }
		}
		private String _Desc2V4;
		public String Desc2V4
		{
			get { return _Desc2V4; }
			set { _Desc2V4 = value; }
		}
		private String _Desc2V5;
		public String Desc2V5
		{
			get { return _Desc2V5; }
			set { _Desc2V5 = value; }
		}
		private DateTime _Date1;
		public DateTime Date1
		{
			get { return _Date1; }
			set { _Date1 = value; }
		}
		private DateTime _Date2;
		public DateTime Date2
		{
			get { return _Date2; }
			set { _Date2 = value; }
		}
		private DateTime _Date3;
		public DateTime Date3
		{
			get { return _Date3; }
			set { _Date3 = value; }
		}
		private DateTime _Date4;
		public DateTime Date4
		{
			get { return _Date4; }
			set { _Date4 = value; }
		}
		private DateTime _Date5;
		public DateTime Date5
		{
			get { return _Date5; }
			set { _Date5 = value; }
		}
		private Int32 _aYear;
		public Int32 aYear
		{
			get { return _aYear; }
			set { _aYear = value; }
		}
		private String _BudgetGroup;
		public String BudgetGroup
		{
			get { return _BudgetGroup; }
			set { _BudgetGroup = value; }
		}
		private String _Department;
		public String Department
		{
			get { return _Department; }
			set { _Department = value; }
		}
		private String _Employee;
		public String Employee
		{
			get { return _Employee; }
			set { _Employee = value; }
		}
		private Int16 _SharedBudget;
		public Int16 SharedBudget
		{
			get { return _SharedBudget; }
			set { _SharedBudget = value; }
		}
		private String _aYearBudgetGroup;
		public String aYearBudgetGroup
		{
			get { return _aYearBudgetGroup; }
			set { _aYearBudgetGroup = value; }
		}
		private Int32 _ImpDate;
		public Int32 ImpDate
		{
			get { return _ImpDate; }
			set { _ImpDate = value; }
		}
		private Int32 _UpdDate;
		public Int32 UpdDate
		{
			get { return _UpdDate; }
			set { _UpdDate = value; }
		}
		private String _sort1;
		public String sort1
		{
			get { return _sort1; }
			set { _sort1 = value; }
		}
		private Double _sort2;
		public Double sort2
		{
			get { return _sort2; }
			set { _sort2 = value; }
		}
        private String _CreatedBy;
        public String CreatedBy
        {
            get { return _CreatedBy; }
            set { _CreatedBy = value; }
        }
        private String _ModifiedBy;
        public String ModifiedBy
        {
            get { return _ModifiedBy; }
            set { _ModifiedBy = value; }
        }
        #endregion LocalVariable
        
        #region Constructor
		public ContrInfo()
		{
			_Contract = "";
			_LimitAmt = 0;
			_LimitAmt1 = 0;
			_CummulativeAmt = 0;
			_RemainingAmt = 0;
			_ContractHolder = "";
			_Desc = "";
			_LimitAmtV1 = 0;
			_LimitAmtV2 = 0;
			_LimitAmtV3 = 0;
			_LimitAmtV4 = 0;
			_LimitAmtV5 = 0;
			_Desc1V1 = "";
			_Desc1V2 = "";
			_Desc1V3 = "";
			_Desc1V4 = "";
			_Desc1V5 = "";
			_Desc2V1 = "";
			_Desc2V2 = "";
			_Desc2V3 = "";
			_Desc2V4 = "";
			_Desc2V5 = "";
			_Date1 = DateTime.Now;
			_Date2 = DateTime.Now;
			_Date3 = DateTime.Now;
			_Date4 = DateTime.Now;
			_Date5 = DateTime.Now;
			_aYear = -1;
			_BudgetGroup = "";
			_Department = "";
			_Employee = "";
			_SharedBudget = (Int16)0;
			_aYearBudgetGroup = "";
			_ImpDate = -1;
			_UpdDate = -1;
			_sort1 = "";
			_sort2 = 0;
            _CreatedBy = "";
            _ModifiedBy = "";
		}
		public ContrInfo(
			String Contract,
			Double LimitAmt,
			Double LimitAmt1,
			Double CummulativeAmt,
			Double RemainingAmt,
			String ContractHolder,
			String Desc,
			Double LimitAmtV1,
			Double LimitAmtV2,
			Double LimitAmtV3,
			Double LimitAmtV4,
			Double LimitAmtV5,
			String Desc1V1,
			String Desc1V2,
			String Desc1V3,
			String Desc1V4,
			String Desc1V5,
			String Desc2V1,
			String Desc2V2,
			String Desc2V3,
			String Desc2V4,
			String Desc2V5,
			DateTime Date1,
			DateTime Date2,
			DateTime Date3,
			DateTime Date4,
			DateTime Date5,
			Int32 aYear,
			String BudgetGroup,
			String Department,
			String Employee,
			Int16 SharedBudget,
			String aYearBudgetGroup,
			Int32 ImpDate,
			Int32 UpdDate,
			String sort1,
			Double sort2,
            String CreatedBy,
            String ModifiedBy
			)
		{
			_Contract = Contract;
			_LimitAmt = LimitAmt;
			_LimitAmt1 = LimitAmt1;
			_CummulativeAmt = CummulativeAmt;
			_RemainingAmt = RemainingAmt;
			_ContractHolder = ContractHolder;
			_Desc = Desc;
			_LimitAmtV1 = LimitAmtV1;
			_LimitAmtV2 = LimitAmtV2;
			_LimitAmtV3 = LimitAmtV3;
			_LimitAmtV4 = LimitAmtV4;
			_LimitAmtV5 = LimitAmtV5;
			_Desc1V1 = Desc1V1;
			_Desc1V2 = Desc1V2;
			_Desc1V3 = Desc1V3;
			_Desc1V4 = Desc1V4;
			_Desc1V5 = Desc1V5;
			_Desc2V1 = Desc2V1;
			_Desc2V2 = Desc2V2;
			_Desc2V3 = Desc2V3;
			_Desc2V4 = Desc2V4;
			_Desc2V5 = Desc2V5;
			_Date1 = Date1;
			_Date2 = Date2;
			_Date3 = Date3;
			_Date4 = Date4;
			_Date5 = Date5;
			_aYear = aYear;
			_BudgetGroup = BudgetGroup;
			_Department = Department;
			_Employee = Employee;
			_SharedBudget = SharedBudget;
			_aYearBudgetGroup = aYearBudgetGroup;
			_ImpDate = ImpDate;
			_UpdDate = UpdDate;
			_sort1 = sort1;
			_sort2 = sort2;
            _CreatedBy = CreatedBy;
            _ModifiedBy = ModifiedBy;
		}
		public ContrInfo(DataRow dr)
		{
			if (dr != null)
			{
                _Contract = dr["BudgetCode"] == DBNull.Value ? "" : (String)dr["BudgetCode"];
                _LimitAmt = dr["LimitAmt"] == DBNull.Value ? 0 : (Double)dr["LimitAmt"];
                _LimitAmt1 = 0;
                _CummulativeAmt = dr["Requisition"] == DBNull.Value ? 0 : (Double)dr["Requisition"];
                _RemainingAmt = dr["Remaining"] == DBNull.Value ? 0 : (Double)dr["Remaining"];
                _ContractHolder = dr["Holder"] == DBNull.Value ? "" : (String)dr["Holder"];
                _Desc = dr["Description"] == DBNull.Value ? "" : (String)dr["Description"];
                _LimitAmtV1 = dr["ValueV1"] == DBNull.Value ? 0 : (Double)dr["ValueV1"];
                _LimitAmtV2 = dr["ValueV2"] == DBNull.Value ? 0 : (Double)dr["ValueV2"];
                _LimitAmtV3 = dr["ValueV3"] == DBNull.Value ? 0 : (Double)dr["ValueV3"];
                _LimitAmtV4 = dr["ValueV4"] == DBNull.Value ? 0 : (Double)dr["ValueV4"];
                _LimitAmtV5 = dr["ValueV5"] == DBNull.Value ? 0 : (Double)dr["ValueV5"];
                _Desc1V1 = dr["Note1V1"] == DBNull.Value ? "" : (String)dr["Note1V1"];
                _Desc1V2 = dr["Note1V2"] == DBNull.Value ? "" : (String)dr["Note1V2"];
                _Desc1V3 = dr["Note1V3"] == DBNull.Value ? "" : (String)dr["Note1V3"];
                _Desc1V4 = dr["Note1V4"] == DBNull.Value ? "" : (String)dr["Note1V4"];
                _Desc1V5 = dr["Note1V5"] == DBNull.Value ? "" : (String)dr["Note1V5"];
                _Desc2V1 = dr["Note2V1"] == DBNull.Value ? "" : (String)dr["Note2V1"];
                _Desc2V2 = dr["Note2V2"] == DBNull.Value ? "" : (String)dr["Note2V2"];
                _Desc2V3 = dr["Note2V3"] == DBNull.Value ? "" : (String)dr["Note2V3"];
                _Desc2V4 = dr["Note2V4"] == DBNull.Value ? "" : (String)dr["Note2V4"];
                _Desc2V5 = dr["Note2V5"] == DBNull.Value ? "" : (String)dr["Note2V5"];
                _Date1 = dr["DateV1"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["DateV1"];
                _Date2 = dr["DateV2"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["DateV2"];
                _Date3 = dr["DateV3"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["DateV3"];
                _Date4 = dr["DateV4"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["DateV4"];
                _Date5 = dr["DateV5"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["DateV5"];
                _aYear = dr["Year"] == DBNull.Value ? -1 : (Int32)dr["Year"];
                _BudgetGroup = dr["Group"] == DBNull.Value ? "" : (String)dr["Group"];
                _Department = dr["Dep"] == DBNull.Value ? "" : (String)dr["Dep"];
                _Employee = dr["Emp"] == DBNull.Value ? "" : (String)dr["Emp"];
                _SharedBudget = dr["isShared"] == DBNull.Value ? (Int16)0 : (Int16)dr["isShared"];
                _aYearBudgetGroup = "";
                _ImpDate = DateTime.Now.Day;
                _UpdDate = DateTime.Now.Day;
                _sort1 = "";
                _sort2 = 0;
                _CreatedBy = dr["CreatedBy"] == DBNull.Value ? "" : (String)dr["CreatedBy"];
                _ModifiedBy = dr["ModifiedBy"] == DBNull.Value ? "" : (String)dr["ModifiedBy"];
			}
		}
        public ContrInfo(DataRowView dr)
        {
            if (dr != null)
            {
                _Contract = dr["BudgetCode"] == DBNull.Value ? "" : (String)dr["BudgetCode"];
                _LimitAmt = dr["LimitAmt"] == DBNull.Value ? 0 : (Double)dr["LimitAmt"];
                //_LimitAmt1 = dr["LimitAmt1"] == DBNull.Value ? 0 : (Double)dr["LimitAmt1"];
                _CummulativeAmt = dr["Requisition"] == DBNull.Value ? 0 : (Double)dr["Requisition"];
                _RemainingAmt = dr["Remaining"] == DBNull.Value ? 0 : (Double)dr["Remaining"];
                _ContractHolder = dr["Holder"] == DBNull.Value ? "" : (String)dr["Holder"];
                _Desc = dr["Description"] == DBNull.Value ? "" : (String)dr["Description"];
                _LimitAmtV1 = dr["ValueV1"] == DBNull.Value ? 0 : (Double)dr["ValueV1"];
                _LimitAmtV2 = dr["ValueV2"] == DBNull.Value ? 0 : (Double)dr["ValueV2"];
                _LimitAmtV3 = dr["ValueV3"] == DBNull.Value ? 0 : (Double)dr["ValueV3"];
                _LimitAmtV4 = dr["ValueV4"] == DBNull.Value ? 0 : (Double)dr["ValueV4"];
                _LimitAmtV5 = dr["ValueV5"] == DBNull.Value ? 0 : (Double)dr["ValueV5"];
                _Desc1V1 = dr["Note1V1"] == DBNull.Value ? "" : (String)dr["Note1V1"];
                _Desc1V2 = dr["Note1V2"] == DBNull.Value ? "" : (String)dr["Note1V2"];
                _Desc1V3 = dr["Note1V3"] == DBNull.Value ? "" : (String)dr["Note1V3"];
                _Desc1V4 = dr["Note1V4"] == DBNull.Value ? "" : (String)dr["Note1V4"];
                _Desc1V5 = dr["Note1V5"] == DBNull.Value ? "" : (String)dr["Note1V5"];
                _Desc2V1 = dr["Note2V1"] == DBNull.Value ? "" : (String)dr["Note2V1"];
                _Desc2V2 = dr["Note2V2"] == DBNull.Value ? "" : (String)dr["Note2V2"];
                _Desc2V3 = dr["Note2V3"] == DBNull.Value ? "" : (String)dr["Note2V3"];
                _Desc2V4 = dr["Note2V4"] == DBNull.Value ? "" : (String)dr["Note2V4"];
                _Desc2V5 = dr["Note2V5"] == DBNull.Value ? "" : (String)dr["Note2V5"];
                _Date1 = dr["DateV1"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["DateV1"];
                _Date2 = dr["DateV2"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["DateV2"];
                _Date3 = dr["DateV3"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["DateV3"];
                _Date4 = dr["DateV4"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["DateV4"];
                _Date5 = dr["DateV5"] == DBNull.Value ? DateTime.MinValue : (DateTime)dr["DateV5"];
                _aYear = dr["Year"] == DBNull.Value ? -1 : (Int32)dr["Year"];
                _BudgetGroup = dr["Group"] == DBNull.Value ? "" : (String)dr["Group"];
                _Department = dr["Dep"] == DBNull.Value ? "" : (String)dr["Dep"];
                _Employee = dr["Emp"] == DBNull.Value ? "" : (String)dr["Emp"];
                _SharedBudget = dr["isShared"] == DBNull.Value ? (Int16)0 : (Int16)dr["isShared"];
                //_aYearBudgetGroup = dr["aYearBudgetGroup"] == DBNull.Value ? "" : (String)dr["aYearBudgetGroup"];
                //_ImpDate = dr["ImpDate"] == DBNull.Value ? -1 : (Int32)dr["ImpDate"];
                //_UpdDate = dr["UpdDate"] == DBNull.Value ? -1 : (Int32)dr["UpdDate"];
                //_sort1 = dr["sort1"] == DBNull.Value ? "" : (String)dr["sort1"];
                //_sort2 = dr["sort2"] == DBNull.Value ? 0 : (Double)dr["sort2"];
            }
        }
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("TblContr");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn("BudgetCode", typeof(String)),
				new DataColumn("LimitAmt", typeof(Double)),
                new DataColumn("LimitAmt1", typeof(Double)),
				new DataColumn("Requisition", typeof(Double)),
				new DataColumn("Remaining", typeof(Double)),
				new DataColumn("Holder", typeof(String)),
				new DataColumn("Description", typeof(String)),
				new DataColumn("ValueV1", typeof(Double)),
				new DataColumn("ValueV2", typeof(Double)),
				new DataColumn("ValueV3", typeof(Double)),
				new DataColumn("ValueV4", typeof(Double)),
				new DataColumn("ValueV5", typeof(Double)),
				new DataColumn("Note1V1", typeof(String)),
				new DataColumn("Note1V2", typeof(String)),
				new DataColumn("Note1V3", typeof(String)),
				new DataColumn("Note1V4", typeof(String)),
				new DataColumn("Note1V5", typeof(String)),
				new DataColumn("Note2V1", typeof(String)),
				new DataColumn("Note2V2", typeof(String)),
				new DataColumn("Note2V3", typeof(String)),
				new DataColumn("Note2V4", typeof(String)),
				new DataColumn("Note2V5", typeof(String)),
				new DataColumn("DateV1", typeof(DateTime)),
				new DataColumn("DateV2", typeof(DateTime)),
				new DataColumn("DateV3", typeof(DateTime)),
				new DataColumn("DateV4", typeof(DateTime)),
				new DataColumn("DateV5", typeof(DateTime)),
				new DataColumn("Year", typeof(Int32)),
				new DataColumn("Group", typeof(String)),
				new DataColumn("Dep", typeof(String)),
				new DataColumn("Emp", typeof(String)),
				new DataColumn("isShared", typeof(Int16)),
                new DataColumn("aYearBudgetGroup", typeof(String)),
                new DataColumn("ImpDate", typeof(Int32)),
                new DataColumn("UpdDate", typeof(Int32)),
                new DataColumn("sort1", typeof(String)),
                new DataColumn("sort2", typeof(Double)),
                new DataColumn("CreatedBy", typeof(String)),
                new DataColumn("ModifiedBy", typeof(String))
				});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row["Contract"] = _Contract;
			row["LimitAmt"] = _LimitAmt;
			row["LimitAmt1"] = _LimitAmt1;
			row["CummulativeAmt"] = _CummulativeAmt;
			row["RemainingAmt"] = _RemainingAmt;
			row["ContractHolder"] = _ContractHolder;
			row["Desc"] = _Desc;
			row["LimitAmtV1"] = _LimitAmtV1;
			row["LimitAmtV2"] = _LimitAmtV2;
			row["LimitAmtV3"] = _LimitAmtV3;
			row["LimitAmtV4"] = _LimitAmtV4;
			row["LimitAmtV5"] = _LimitAmtV5;
			row["Desc1V1"] = _Desc1V1;
			row["Desc1V2"] = _Desc1V2;
			row["Desc1V3"] = _Desc1V3;
			row["Desc1V4"] = _Desc1V4;
			row["Desc1V5"] = _Desc1V5;
			row["Desc2V1"] = _Desc2V1;
			row["Desc2V2"] = _Desc2V2;
			row["Desc2V3"] = _Desc2V3;
			row["Desc2V4"] = _Desc2V4;
			row["Desc2V5"] = _Desc2V5;
			row["Date1"] = _Date1;
			row["Date2"] = _Date2;
			row["Date3"] = _Date3;
			row["Date4"] = _Date4;
			row["Date5"] = _Date5;
			row["aYear"] = _aYear;
			row["BudgetGroup"] = _BudgetGroup;
			row["Department"] = _Department;
			row["Employee"] = _Employee;
			row["SharedBudget"] = _SharedBudget;
			row["aYearBudgetGroup"] = _aYearBudgetGroup;
			row["ImpDate"] = _ImpDate;
			row["UpdDate"] = _UpdDate;
			row["sort1"] = _sort1;
			row["sort2"] = _sort2;
			return row;
		}

        #endregion InitTable
    }
}
